package com.yantong.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 *mvc自定义适配器
 * @author kanghaixin
 * @date 2017/4/20
 */
@Configuration
public class SelfWebAppConfigurer extends WebMvcConfigurerAdapter {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOriginPatterns("*")
                .allowedHeaders("*") // 允许请求头
                .allowedMethods("*")
                .maxAge(3600)
                .allowCredentials(true);
    }
}
